#ifndef __462A581B_65BA_411a_A1AD_A03350BA2B4A__
#define __462A581B_65BA_411a_A1AD_A03350BA2B4A__

#include "heart_acceptor.h"
#include "../import/head.h"
#include "../tools/head.h"

/////////////////////////////////////////////////////////////////////////////////////////
// 

namespace xos
{
    // 
    // heart_impl
    // 
    class heart_impl : public xos_stl::mem_pool_item< heart_impl, thread_lock >,
        public i_heart
    {
    public:
        heart_impl();
        ~heart_impl();

    protected:
        static void * thread( void * lpData );
        int scan();

        heart_acceptor::LIST m_accept_list;
        xos_i32 m_iScanInterval;
        thread_lock m_lock;
        i_thread * m_pThread;
        i_event * m_pEvent;
        bool m_bQuit;

    public:
        int init();
        int term();

    public:
        // 
        // set heart interval
        // 
        int set_interval( xos_i32 iMilliSecondInterval );

        // 
        // add acceptor
        // 
        int add_acceptor( i_acceptor * pAcceptor, xos_i32 iInterval );

        // 
        // remove acceptor
        // 
        int rem_acceptor( i_acceptor * pAcceptor );

        // 
        // release
        // 
        int release();
    };
} // xos

#endif // __462A581B_65BA_411a_A1AD_A03350BA2B4A__
